package ModelLayer;



import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class LoanTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class LoanTest
{
    /**
     * Default constructor for test class LoanTest
     */
    public LoanTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
    }

    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }
    
    
    
    @Test
    public void testSetId()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi");  
        loan.setId(2);
        assertEquals(2, loan.getId());    
    }
    
    @Test
    public void testGetId()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi");        
        assertEquals(0, loan.getId());    
    }  
    
           
    @Test
    public void testSetBorrowDate()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi");  
        loan.setBorrowDate(1102);
        assertEquals(1102, loan.getBorrowDate());    
    }
    
    @Test
    public void testGetBorrowDate()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi");  
        loan.setBorrowDate(1);
        assertEquals(1, loan.getBorrowDate());    
    }
    
    
       
    @Test
    public void testSetBorrowPeriod()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi");  
        loan.setBorrowPeriod(1);
        assertEquals(1, loan.getBorrowPeriod());    
    }
    
    @Test
    public void testGetBorrowPeriod()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi");  
        loan.setBorrowPeriod(1);
        assertEquals(1, loan.getBorrowPeriod());    
    }
    
    
       
    @Test
    public void testSetState()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi");  
        loan.setState("omg");
        assertEquals("omg", loan.getState());    
    }
    
    
    
    @Test
    public void testGetLoaner()
    {
        DVD dvd = new DVD(2, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(2, 15, 15, dvd);
        Person person = new Person(2, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(2,2,2,2,2,2,"hi");
        assertNotNull(loan.getLoaner());
    }
    
    
    @Test
    public void testGetCopy()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi"); 
        assertNotNull(loan.getCopy());
    }   
    
    @Test
    public void testReturnStateExpired()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi"); 
        assertEquals("Expired but returned",loan.returnState(867000000) );
    }
    
    @Test
    public void testReturnStateReturned()
    {
        DVD dvd = new DVD(0, "Dvd", "DMX", 156);
        DVDRecords.getInstance().addDVD(dvd);
        Copy copy = new Copy(0, 15, 15, dvd);
        Person person = new Person(0, "Ivcho", "Otsreshta", 1517, "Sofia", 12); 
        Loan loan = new Loan(0,0,0,0,0,0,"hi"); 
        assertEquals("Returned", loan.returnState(1));
    }
}
